package com.ledim.ledimview;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ledim.itf.YanViewEventObserver;
import com.letv.android.young.client.R;

public class YanInputBaseView extends LinearLayout implements View.OnClickListener {

    protected ImageView mDel;
    protected YanViewEventObserver observer;

    public void setObserver(YanViewEventObserver observer) {
        this.observer = observer;
    }

    public YanInputBaseView(Context context) {
        super(context);
    }

    public YanInputBaseView(Context context, AttributeSet attrs) {
        super(context, attrs);

    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public YanInputBaseView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        init();
    }

    protected void init() {
        findViewById(R.id.yan_text_one).setOnClickListener(this);
        findViewById(R.id.yan_text_two).setOnClickListener(this);
        findViewById(R.id.yan_text_three).setOnClickListener(this);
        findViewById(R.id.yan_text_four).setOnClickListener(this);
        findViewById(R.id.yan_text_five).setOnClickListener(this);
        findViewById(R.id.yan_text_six).setOnClickListener(this);
        findViewById(R.id.yan_text_seven).setOnClickListener(this);
        mDel = (ImageView) findViewById(R.id.yan_view_del);
        mDel.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (observer != null) {
            if (v == mDel) {
                observer.onYanEmojDel();
            } else {
                observer.onYanEmojInput(((TextView) v).getText().toString());
            }
        }

    }

}
